<?php
class DBMysql{

	//设置连接信息
	public function dbc()
	{
		$dbc = @mysqli_connect('localhost', 'root', '','beauty')OR die('Could not connected to MySQL:'.mysqli_error());
		//$db_selected = mysqli_select_db('beauty',$dbc);
		$program_char = 'utf8';
		mysqli_set_charset($dbc,$program_char);
		//mysqli_client_encoding($dbc);
		//mysqli_client_encoding($dbc);
		mysqli_query('set character_set_results=utf8');
		mysqli_query('SET NAMES utf8');
		return $dbc;
	}

	/**
	 * 查询返回结果集
	 */
	public function query($sql)
	{
		$dbc = $this->dbc();
		$result = mysqli_query($dbc,$sql);
		return $result;
	}

	/**
	 * 查询返回结果集
	 */
	public function fetch($sql)
	{
		$result = $this->query($sql);
		$fetch = mysqli_fetch_array($result);
		return $fetch;
	}
}